<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorate="layout">
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>用户管理</title>
    <script src="js/emplist/empList.js"></script>
</head>

<body>
<div  layout:fragment="content">
    <div class="container-fluid">
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h1 class="h2">用户管理</h1>
            </div>
            <div class="row" style="margin-bottom: 15px">
                <span>&nbsp;&nbsp;&nbsp;</span>
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addEmp">添加用户</button>
            </div>

            <div>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th scope="col">#</th>
                        <th scope="col">用户名</th>
                        <th scope="col">密码</th>
                        <th scope="col">邮箱</th>
                        <th scope="col">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each=" emp:${empList}">
                        <th scope="row"></th>
                        <td th:text="${emp.username}"></td>
                        <td th:text="${emp.password}"></td>
                        <td th:text="${emp.email}"></td>
                        <td>
                            <a href="#" class="btn btn-danger btn-sm active" role="button" aria-pressed="true" th:onclick="deleteEmp([[${emp.id}]])">删除</a>
                            <a href="#" class="btn btn-success btn-sm active" role="button" aria-pressed="true" th:onclick="editEmp([[${emp}]])">编辑</a>
                        </td>
                    </tr>
                    </tbody>
                </table>

            </div>
        </main>
    </div>
    <!--员工添加模态窗口-->
    <div class="modal fade" id="addEmp" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel"><span style="color: #0c5460;font-weight: bold">添加用户</span></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form name="form1" class="form-horizontal">
                        <input type="hidden" class="form-control col-sm-8"  id="userId" >
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">用户名:</label>
                            <input type="text" class="form-control col-sm-8" id="userName" >
                        </div>
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">密码:</label>
                            <input type="text" class="form-control col-sm-8" id="userPwd">
                        </div>
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">邮箱:</label>
                            <input type="text" class="form-control col-sm-8" id="userEmail">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" onclick="save()">提交</button>
                </div>
            </div>
        </div>
    </div>

    <!--用户更新模态窗口-->
    <div class="modal fade" id="updateEmp" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel1"><span style="color: #1e7e34;font-weight: bold">编辑用户</span> </h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <input type="hidden" class="form-control col-sm-8"  id="userId1" >
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">用户名:</label>
                            <input type="text" class="form-control col-sm-8" id="userName1" >
                        </div>
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">密码:</label>
                            <input type="text" class="form-control col-sm-8" id="userPwd1">
                        </div>
                        <div class="form-group row">
                            <label class="col-form-label col-sm-2">邮箱:</label>
                            <input type="text" class="form-control col-sm-8" id="userEmail1">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" onclick="save1()">提交</button>
                </div>
            </div>
        </div>
    </div>

</div>
</body>

</html>
